class GameScene extends BaseScene{

	private floorGroup:egret.DisplayObjectContainer;
	private floorBox1:egret.DisplayObjectContainer;
	private floorBox2:egret.DisplayObjectContainer;
	private curfloorBox:egret.DisplayObjectContainer;
	private roleGroup:eui.Group;

	private fingerImg:eui.Image;
	private fingerImgName:string="finger1_png";

	// 包含分数及各个操作按钮的容器
	private scoreGroup:eui.Group;
	private pauseBtn:eui.Image;
	private scoreLbl:eui.Label;
	private giftImg:eui.Image;
	private giftTimeLbl1:eui.Label;
	private giftTimeLbl2:eui.Label;
	private giftTimeLbl3:eui.Label;
	private giftStartTime:number = 0;

	private bgImg2:eui.Image;
	private rocketCard:eui.Image;
	private rocketNumLbl:eui.BitmapLabel;
	private speedCard:eui.Image;
	private speedNumLbl:eui.BitmapLabel;
	private rocketBtn:eui.Image;
	private speedBtn:eui.Image;

	// 背景图片
	private bgImg:eui.Image;

	// 出现限时礼包的容器及内容
	private giftGroup:eui.Group;
	private useGiftBtn:eui.Image;
	private closeGiftBtn:eui.Image;

	
	private isPause:boolean = false;
	private isGameOver:boolean = false;
	private isRealGameOver:boolean = false;
	private isReborning:boolean = false;

	private isJumping:boolean = false;
	private isOnlyJumpUp:boolean = false;
	private currentFloorFromMoveY:number = 0;
	private isJumpingUp:boolean = false;
	private isJumpingDown:boolean = false;
	private isRocketJumping:boolean = false;
	private isQuickJumping:boolean = false;
	private isShareCanCallBack:boolean = false;
	/**快速移动开始时间 */
	private highSpeedBeginTime:number = 0;
	/**快速移动持续时间 */
	private highSpeedContinueTime:number = 0;
	// 人物是否是从左侧到右侧
	private isRoleFromLeft2Right:boolean = true;
	private quickTapCount:number = 0;
	private lastTapTime:number = 0;

	private _armature1: dragonBones.Armature = null;  //人物行走；
    private _armature2: dragonBones.Armature = null;  //人物停止移动；
	private _curArmture: dragonBones.Armature = null;
	private _rocketArmature: dragonBones.Armature = null;
	private quickRunAramture1: dragonBones.Armature = null;
	private quickRunAramture2: dragonBones.Armature = null;
	private _curQuickRunAramture: dragonBones.Armature = null;

	private currentFloor:GameFloor = null;
	private lastFloor:GameFloor = null;
	private safeFloor:GameFloor = null;
	private safeIndex:number = 0;
	private floorArray:Array<GameFloor> = [];
	/**第一层楼距离底部的位置 */
	private floorBottom = 170;
	private minRoleY = 150;

	private upSpeed:number = 0;
	private downSpeed:number = 0;

	public constructor(index:number = GameConfig.uiIndex.game) {
		super(index);
		this.skinName = "GameSceneSkin";
		//this.skinName = "HomeSceneSkin";
		platform.callPlatformMethod("triggerGC",{});
	}

	//重载
	public onChildrenCreated() {
		super.onChildrenCreated();

		this.height = GameConfig.stageHeight;
		this.width = GameConfig.stageWidth;
		
		let scroll = new egret.ScrollView();
		scroll.x = 0;
		scroll.y = 0;
		scroll.verticalScrollPolicy = "off";
		scroll.horizontalScrollPolicy = "off";
		scroll.width = GameConfig.stageWidth;
		scroll.height = this.height-this.floorBottom;
		this.addChildAt(scroll,1);
		this.floorGroup = new egret.DisplayObjectContainer();
		scroll.setContent(this.floorGroup);

		this.resetDataAndViews();
		this.setupDataAndViews();
		this.initViewLocation();
		if(UserData.highest_score<30){
			this.showCountdown();
		}else{
			this.isPause = false;
		}
		
		this.startMove();
	}
	private initViewLocation(){
		
		let leftMargin=56;
		let rightMargin=56;
		this.bgImg.source = "bg"+UserData.current_bgId+"_jpg";
		UserData.hasGiftPackage = false;

	}
	/**
	 * 将数据和View复原
	 */
	private resetDataAndViews(){
		UserData.score = 1;
		UserData.speedCardNum = 1;
		UserData.rocketCardNum = 1;
		UserData.deadTimes = 0;
		UserData.hasGiftPackage = false;
		this.rocketNumLbl.text = "x"+UserData.rocketCardNum;
		this.speedNumLbl.text = "x"+UserData.speedCardNum;
		UserData.roleSpeed = UserData.roleNormalSpeed;
		this.isQuickJumping = false;
		this.isReborning = false;
		this.scoreLbl.text = ""+UserData.score;
		this.currentFloor = null;
		this.lastFloor = null;
		this.isPause = false;
		this.isGameOver = false;
		this.isRealGameOver = false;
		this.isJumping = false;
		this.isOnlyJumpUp = false;
		this.currentFloorFromMoveY = 0;
		this.isJumpingUp = false;
		this.isJumpingDown = false;
		this.isRocketJumping = false;
		this.highSpeedBeginTime = 0;
		this.highSpeedContinueTime = 0;
		this.isRoleFromLeft2Right = true;
		this.quickTapCount = 0;
		this.lastTapTime = 0;
		for(let i=0;i<this.floorArray.length;i++){
			let floor = this.floorArray[i];
			GameConfig.saveFloor(floor);
		}
		this.floorArray = [];
		if(this.floorBox1){
			this.floorBox1.y = (GameConfig.stageHeight-this.floorBottom)-this.floorBox1.height;
			if(this.floorBox2){
				this.floorBox2.y = this.floorBox1.y-this.floorBox2.height;
			}
		}
		
		this.giftGroup.visible = false;
		this.giftImg.visible = false;
	}
	/**
	 * 设置展示的砖块、球、红心、分数等
	 */
	private setupDataAndViews(){
		

		let len = Math.floor((GameConfig.stageHeight-this.floorBottom+GameConfig.floorHeight-1)/GameConfig.floorHeight);
		let floorHeight = GameConfig.floorHeight;
		let boxHeight = floorHeight*len;
		let boxY = GameConfig.stageHeight-this.floorBottom-boxHeight;
		let boxWidth = GameConfig.stageWidth;

		let floorGroupHeight = GameConfig.stageHeight-this.floorBottom;
		if(!this.floorBox1){
			this.floorBox1 = new egret.DisplayObjectContainer();
			this.floorBox1.x = 0;
			this.floorBox1.width = GameConfig.stageWidth;
			this.floorBox1.height = floorHeight*len;
			this.floorBox1.y = floorGroupHeight-this.floorBox1.height;
			this.floorGroup.addChildAt(this.floorBox1,0);
			// let img1 = new eui.Image();
			// img1.x = 0;
			// img1.y = 0;
			// img1.width = this.floorBox1.width;
			// img1.height = this.floorBox1.height;
			// img1.source = "bg1_jpg";
			// this.floorBox1.addChild(img1);
		}
		if(!this.floorBox2){
			this.floorBox2 = new egret.DisplayObjectContainer();
			this.floorBox2.x = 0;
			this.floorBox2.width = GameConfig.stageWidth;
			this.floorBox2.height = floorHeight*len;
			this.floorBox2.y = this.floorBox1.y-this.floorBox2.height;
			this.floorGroup.addChildAt(this.floorBox2,0);
			// let img2 = new eui.Image();
			// img2.x = 0;
			// img2.y = 0;
			// img2.width = this.floorBox2.width;
			// img2.height = this.floorBox2.height;
			// img2.source = "bg2_jpg";
			// this.floorBox2.addChild(img2);
		}
		this.curfloorBox = this.floorBox1;
		// let lastFloorY = GameConfig.stageHeight-this.floorBottom;
		let lastFloorY = this.floorBox1.height;
		for(let i=0;i<len;i++){
			let floor:GameFloor = null;
			if(i==0){
				let lastHardLevel = GameHardLevel.createFirstLevel(lastFloorY);
				floor = new GameFloor(lastHardLevel);
			}else{
				floor = GameConfig.getFoor(this.lastFloor);
			}
			this.lastFloor = floor;
			this.curfloorBox.addChild(floor);
			if(floor.y == 0){
				floor.hardLevel.lastFloorY = this.floorBox1.height;
				this.curfloorBox = this.floorBox2;
			}
			if(i==0){
				this.currentFloor = floor;
			}
			this.floorArray.push(floor);
		}
		if(!this.roleGroup){
			this.roleGroup = new eui.Group();
			this.roleGroup.x = this.currentFloor.x+GameConfig.floorBorder;
			this.roleGroup.height = 65;
			this.roleGroup.width = 56;
			this.scoreGroup.addChild(this.roleGroup);
			this.changeAnim();
		}
		this.updateRoleXY();
		
	}
	private updateRoleXY(){
		let shouldY = this.currentFloor.parent.y+ViewUtils.bottomOfView(this.currentFloor)-GameConfig.floorBorder-this.roleGroup.height;		
		if(shouldY != this.roleGroup.y && shouldY>=(this.minRoleY-50)){
			this.roleGroup.y = shouldY;
			this.roleGroup.height = 65;
			this.roleGroup.width = 56;
			let displayAnim =  this._curArmture.display;
			displayAnim.x = this.roleGroup.width/2;
			displayAnim.y = this.roleGroup.height/2;
		}
		
	}

	private closeGuide(){
		
		// 回到开始页面后重新发送要展示使用共享数据域展示超越排名的功能
		if(GameConfig.showGameScenceRank){
			//OpenDataUtil.showRank(this,{uiIndex: this.index});
		}
		
		this.isPause = true;
		this.showCountdown();
		
		
	}
	private showCountdown(){
		this.isPause = true;
		this.fingerImg = new eui.Image();
		this.fingerImg.source = this.fingerImgName;
		this.fingerImg.x = this.width-this.fingerImg.width-189;
		this.fingerImg.y = this.height-this.floorBottom-GameConfig.floorHeight*2-this.fingerImg.height;
		this.addChild(this.fingerImg);

		let img = new eui.Image();
		img.source = "countDownBg_png";
		img.width = 153*0.8;
		img.height = 124*0.8;
		img.x = (this.width-img.width)/2;
		img.y = (this.height-img.height)/2;
		this.addChild(img);
		//let lbl3 = new eui.BitmapLabel();
		//lbl3.font = "maxFont_fnt";
		let lbl3 = new eui.Label();
		lbl3.textColor = 0x231F20;
		lbl3.size = 44;
		//ViewUtils.setframeOfView(lbl3,ViewUtils.getframeOfView(img));
		lbl3.horizontalCenter = egret.HorizontalAlign.CENTER;
		lbl3.verticalCenter = egret.VerticalAlign.MIDDLE;
		
		lbl3.text = "3";
		// lbl3.anchorOffsetX = lbl3.width/2;
		// lbl3.anchorOffsetY = lbl3.height/2;
		lbl3.x = img.x+(img.width-lbl3.width)/2;
		lbl3.y = img.y+(img.height-lbl3.height)/2;
		this.addChild(lbl3);
		this.animaMoveNum(img,lbl3,3);
		egret.setTimeout(()=>{
			SoundManager.playEffect(GameConfig.music.countDown);
		},this,1000);
		this.showFingerImg();
	}
	private closeFingerImg(){
		if(this.fingerImg){
			if(this.fingerImg.parent){
				this.fingerImg.parent.removeChild(this.fingerImg);
			}
			this.fingerImg = null;
		}
	}
	private showFingerImg(){
		if(this.fingerImg){
			egret.setTimeout(()=>{
				this.showFingerImg();
			},this,500);
			if(this.fingerImgName == "finger1_png"){
				this.fingerImgName = "finger2_png";
			}else{
				this.fingerImgName = "finger1_png";
			}
			this.fingerImg.source = this.fingerImgName;
		}
	}
	private animaMoveNum(bgImg:eui.Image,lbl1:eui.Label,fromNum:number){
		
		if(fromNum == -1){
			lbl1.parent.removeChild(lbl1);
			bgImg.parent.removeChild(bgImg);
			//this.fingerImg.parent.removeChild(this.fingerImg);
			//this.fingerImg = null;
			this.isPause = false;
			// egret.setTimeout(()=>{
			// 	SoundManager.playEffect(GameConfig.music.dead);
			// },this,300);
			
			return ;
		}
		let toX = (this.width/2-40);
		let toY = this.height/2;
		let endX = -100-250;
		let endY = this.height/2-250;
		if(fromNum == 0){
			lbl1.size = 38;
			lbl1.text = "开始";
			lbl1.x = bgImg.x+(bgImg.width-lbl1.width)/2;
			lbl1.y = bgImg.y+(bgImg.height-lbl1.height)/2;
		}else{
			lbl1.text = fromNum+"";
		}
		
		egret.setTimeout(()=>{
			this.animaMoveNum(bgImg,lbl1,fromNum-1);
		},this,1000);
		// let lbl2:egret.DisplayObject = this.createCountDownNum(fromNum-1);

		// egret.Tween.get(lbl1).to({x:endX,y:endY,scaleX:5,scaleY:5,alpha:0.0},500).call(()=>{
		// 	lbl1.parent.removeChild(lbl1);
		// });
		// egret.Tween.get(lbl2).to({x:toX,y:toY,scaleX:1,scaleY:1,alpha:1},500).call(()=>{
		// 	// SoundManager.playEffect(GameConfig.music.dead);
		// }).wait(400).call(()=>{
		// 	this.animaMoveNum(bgImg,lbl2,fromNum-1);
		// });
	}
	private createCountDownNum(num:number){
		let fromX = this.width;
		let fromY = this.height/2-250;
		let lbl = new eui.BitmapLabel();
		lbl.font = "maxFont_fnt";
		lbl.text = ""+num;
		lbl.anchorOffsetX = lbl.width/2;
		lbl.anchorOffsetY = lbl.height/2;
		lbl.x = fromX;
		lbl.y = fromY;
		lbl.scaleX = 5;
		lbl.scaleY = 5;
		lbl.alpha = 0.0;
		this.addChild(lbl);
		return lbl;
	}
	private removeCurRoleAnim(){
		if(this._curArmture){
			this._curArmture.animation.stop();
			let displayObj = this._curArmture.display as egret.DisplayObject;
			if(displayObj && displayObj.parent){
				displayObj.parent.removeChild(displayObj);
			}

			this._curArmture = null;
		}
	}

	private changeAnim(){
		if(this.isRoleFromLeft2Right){
			if(!this._armature1){
				 this._armature1 = FuncUtil.dragonBoneTween("roleRight1", "Sprite");
			}
			if(this._curArmture != this._armature1){
				this.removeCurRoleAnim();
				this._curArmture = this._armature1;
			}
			
			
		}else{
			if(!this._armature2){
				 this._armature2 = FuncUtil.dragonBoneTween("roleLeft1", "Sprite");
			}
			if(this._curArmture != this._armature2){
				this.removeCurRoleAnim();
				this._curArmture = this._armature2;
			}
			
		}
		let displayAnim = this._curArmture.display as egret.DisplayObject;
		if(displayAnim && !displayAnim.parent){
			this.roleGroup.addChild(displayAnim);
			ViewUtils.setSizeOfView(this.roleGroup,ViewUtils.getSizeOfView(displayAnim))
			displayAnim.x = this.roleGroup.width/2;
			displayAnim.y = this.roleGroup.height/2;
			this.updateRoleXY();
		}	
		
	}
	private _time:number=0;
    private onTicker() {
		let date = new Date();
		let timeStamp:number = date.getMilliseconds();
		if(this.giftStartTime >0 && UserData.hasGiftPackage && (this.giftGroup.visible || this.giftImg.visible)){
			let nowTime = date.getTime();
			let disTime = nowTime - this.giftStartTime;
			let minTime = Math.floor(disTime/60000);
			let maxMinit = 5;
			if(minTime<maxMinit){
				// 5分钟倒计时
				disTime = maxMinit*60000-disTime;
				// 倒计时分
				minTime = Math.floor(disTime/60000);
				disTime = disTime - minTime*60000;
				// 倒计时秒
				let secTime = Math.floor(disTime/1000);
				disTime = disTime - secTime*1000;
				// 倒计时毫秒
				let mSecTime = Math.floor(disTime/10);
				if(secTime<10){
					this.giftTimeLbl1.text = "0"+minTime+":";
					this.giftTimeLbl2.text = "0"+secTime;
					this.giftTimeLbl3.text = ":"+mSecTime;
				}else{
					this.giftTimeLbl1.text = "0"+minTime+":";
					this.giftTimeLbl2.text = ""+secTime;
					this.giftTimeLbl3.text = ":"+mSecTime;
				}
				
			}else{
				this.giftTimeLbl1.text = "00:";
				this.giftTimeLbl2.text = "00";
				this.giftTimeLbl3.text = ":00";
				this.giftGroup.visible = false;
				this.giftImg.visible = false;
				this.isPause = false;
			}
		}
		// 设置动画播放
		if(this._curArmture){
			if((this.isGameOver || this.isJumping || this.isRocketJumping) && this._curArmture.animation.isPlaying){
				this._curArmture.animation.stop();
			}
			else if((!this.isGameOver && !this.isJumping && !this.isRocketJumping) && !this._curArmture.animation.isPlaying){
				this._curArmture.animation.play();
			}
		}
		// 设置更新实例
		if(!this.isPause){
			dragonBones.WorldClock.clock.advanceTime((timeStamp-this._time) / 1000);
		}
		
		// 设置更新时间
		this._time = timeStamp;
        return false;
    }
	
	private startMove()
	{
		App.TimerManager.doFrame(0, 0, this.loopRunGame, this);
	}
	/**
	 * 每一秒移动球和墙，并检测球是否掉落及碰墙 
	 */

	private loopRunGame(timeStamp:number)
	{
		if(!this.isPause && !this.isGameOver){
			if(this.isJumping && !this.isRocketJumping){
				// 如果前面的以及看不见了就移除
				this.jumpMoveRoleAndFloor();
				this.checkRemoveFloorAndAddFloor();
				
			}
			else if(!this.isJumping && this.isRocketJumping){
				// 使用电梯卡上升
				this.rocketJump2SafeFloor();
				this.checkRemoveFloorAndAddFloor();
			}
			else{
				// 没有暂停游戏、没有结束游戏,没有点击跳动、没有使用电梯卡，要不断移动砖块让球有滚动的效果
				// 移动人物
				this.showQucikRunFire();
				this.moveRole();
				this.checkHitGiftPackage();
			}
			
			if(ViewUtils.rightOfView(this.roleGroup)<GameConfig.floorMargin || ViewUtils.leftOfView(this.roleGroup)>(GameConfig.stageWidth-GameConfig.floorMargin)){
				this.gameOver();
			}
		}else if(!this.isPause && this.isGameOver && !this.isRealGameOver){
			//console.log(">>>gameOver-下降中");
			this.upFloors();
		}
		// 检测结束高速移动
		this.checkStopHighSpeed();
		this.onTicker();

	}
	private upFloors(){
		let firstFloor = this.floorArray[0];
		let firstY = firstFloor.y+firstFloor.parent.y;
		let minY = (GameConfig.stageHeight-this.floorBottom+GameConfig.floorHeight);
		if(firstY <= minY && firstFloor.floorIndex>0){
			let hardLevel = GameHardLevel.createHardLevelByFloor2(firstFloor);
			let floor = new GameFloor(hardLevel);
			floor.y = firstFloor.y+GameConfig.floorHeight;
			firstFloor.parent.addChildAt(floor,0);
			
			this.floorArray = [floor].concat(this.floorArray);
		}
		if(firstFloor.floorIndex !=0 || firstY>=minY){
			this.floorBox1.y = this.floorBox1.y-20;
			this.floorBox2.y = this.floorBox2.y-20;
		}
		
		
	}
	private moveRole(){
		this.updateRoleXY();
		if(this.isRoleFromLeft2Right){
			this.roleGroup.x+=UserData.roleSpeed.roleHorizontalSpeed;
			let roleRight = ViewUtils.rightOfView(this.roleGroup);
			// 到底部时要处理
			if(roleRight>=this.currentFloor.hardLevel.floorRight){
				if(this.currentFloor.hardLevel.hasRightWall){
					this.isRoleFromLeft2Right = false;
					this.changeAnim();

				}else{
					if((roleRight-this.roleGroup.width/2)>=this.currentFloor.hardLevel.floorRight){
						this.roleGroup.x = this.currentFloor.hardLevel.floorRight-this.roleGroup.width/2;
						this.gameOver();
					}
					
				}
			}
		}else{
			this.roleGroup.x-=UserData.roleSpeed.roleHorizontalSpeed;
			let roleLeft = ViewUtils.leftOfView(this.roleGroup);
			
			// 到底部时要处理
			if(roleLeft<=this.currentFloor.hardLevel.floorLeft){
				if(this.currentFloor.hardLevel.hasLeftWall){
					this.isRoleFromLeft2Right = true;
					this.changeAnim();
				}else{
					if((roleLeft+this.roleGroup.width/2)<=this.currentFloor.hardLevel.floorLeft){
						this.roleGroup.x = this.currentFloor.hardLevel.floorLeft+this.roleGroup.width/2;
						this.gameOver();
					}
					
				}
			}
		}
		
	}
	private checkHitGiftPackage(){
		// 检测是否碰到礼包
		if(this.currentFloor.giftImg){
			let roleRight = ViewUtils.rightOfView(this.roleGroup);
			let roleLeft = ViewUtils.leftOfView(this.roleGroup);
			let giftLeft = this.currentFloor.x+this.currentFloor.giftImg.x;
			let giftRight = giftLeft+this.currentFloor.giftImg.width;
			if(giftLeft<=roleRight && roleRight<=giftRight){
				let date = new Date();
				this.giftStartTime = date.getTime();
				this.showGiftPackage();
			}else if(giftLeft<=roleLeft && roleLeft<=giftRight){
				let date = new Date();
				this.giftStartTime = date.getTime();
				this.showGiftPackage();
			}
		}
	}
	private roleJump(evt:egret.TouchEvent){
		if(this.isGameOver || this.isPause){
			return;
		}
		this.closeFingerImg();
		if(this.isRocketJumping){
			return;
		}
		if(this.isJumping){
			
			if(this.isOnlyJumpUp){
				this.updateRoleXY();
				this.isJumping = false;
			}else{

			}
			
		}
		let now = (new Date()).getTime();
		let distanceTime = now-this.lastTapTime;
		
		if(distanceTime>400){
			this.quickTapCount = 0;
		}else{
			this.quickTapCount = this.quickTapCount +1;
		}
		if(this.quickTapCount>=5){
			this.beginHighSpeed(1);
			
		}else{
			
		}
		this.lastTapTime = now;
		
		let index = this.floorArray.indexOf(this.currentFloor);
		let lastFloorY = this.currentFloor.y;
		let jumpIndex = index+1;
		let lastCurrentFloor = this.currentFloor;
		if(this.getFloorYInWindow(lastCurrentFloor)<=GameConfig.floorHeight){
			return;
		}
		
		if(index>=0 && jumpIndex<this.floorArray.length){
			SoundManager.playEffect(GameConfig.music.jumpUp);
			this.currentFloor = this.floorArray[jumpIndex];
			this.addUserScore();
			if(this.roleGroup.x+this.roleGroup.width<this.currentFloor.x || this.roleGroup.x>(this.currentFloor.x+this.currentFloor.width)){
				
				this.gameOver();
				return;
			}
			this.isJumping = true;
			this.isJumpingUp = true;
			this.isJumpingDown = false;
			let currentFloorY = this.getFloorYInWindow(this.currentFloor);
			let centerY = this.height/2;
			// 需要人物和背景一起移动
			if((centerY-currentFloorY)>=GameConfig.floorHeight){
				this.isOnlyJumpUp = false;
				this.currentFloorFromMoveY = currentFloorY;
			}else{
				this.isOnlyJumpUp = true;
			}
			this.upSpeed = UserData.roleSpeed.roleUpSpeed;
		}else{
			//console.log("已经找不到下一个梯步了",distanceTime);
		}
	}
	/**获取floor相对于窗口所在的位置 */
	private getFloorYInWindow(floor:GameFloor):number{
		return floor.parent.y+floor.y;
	}
	private addUserScore(){
		UserData.score = this.currentFloor.hardLevel.floorIndex + 1;
		this.scoreLbl.text = ""+UserData.score;
		if(GameConfig.showGameScenceRank){
			// OpenDataUtil.postMessage({status: GameConfig.shareCavansCommand.SHOW_RANK,
			// 	mine: UserData.getMineOpenData(),
			// 	uiIndex: this.index});
		}
	}
	/**点击跳跃移动 */
	private jumpMoveRoleAndFloor(){
		if(!this.isJumping){
			return;
		}
		this.showQucikRunFire();
		if(this.isRoleFromLeft2Right){
			this.roleGroup.x = this.roleGroup.x+UserData.roleSpeed.roleHorizontalSpeed;
			let roleRight = this.roleGroup.x+this.roleGroup.width;
			let floorRight = ViewUtils.rightOfView(this.currentFloor)-GameConfig.floorBorder;
			if(this.currentFloor.hardLevel.hasRightWall && roleRight>=floorRight){
				this.isRoleFromLeft2Right = false;
				this.changeAnim();
				this.roleGroup.x = floorRight-this.roleGroup.width;
			}
		}else{
			this.roleGroup.x = this.roleGroup.x-UserData.roleSpeed.roleHorizontalSpeed;
			
			let roleLeft = this.roleGroup.x;
			let floorLeft = this.currentFloor.x+GameConfig.floorBorder;
			if(this.currentFloor.hardLevel.hasLeftWall && roleLeft<=floorLeft){
				this.isRoleFromLeft2Right = true;
				this.changeAnim();
				this.roleGroup.x = floorLeft;
			}
		}

		if(this.isJumpingUp && !this.isJumpingDown){
			if(!this.isOnlyJumpUp){
				// 人物加速往上升，梯步往下掉
				// 移动梯步
				this.moveAllFloor(UserData.roleSpeed.floorDownSpeed);
			}
			this.isJumpingUp = true;
			this.isJumpingDown = false;
			if(this.upSpeed>UserData.roleSpeed.gravity){
				this.upSpeed = this.upSpeed - UserData.roleSpeed.gravity;
			}
			// this.roleGroup.y = this.roleGroup.y-UserData.roleSpeed.roleUpSpeed;
			if(this.roleGroup.y-this.upSpeed<=this.minRoleY){
				this.roleGroup.y = this.minRoleY-20;
				this.isJumpingUp = false;
				this.isJumpingDown = true;
				this.downSpeed = UserData.roleSpeed.roleDownSpeed;
				return;
			}else{
				this.roleGroup.y = this.roleGroup.y-this.upSpeed;
			}
			
			let roleTop = this.roleGroup.y;
			let roleBottom = this.roleGroup.y+this.roleGroup.height;
			let floorTop = this.getFloorYInWindow(this.currentFloor);
			let floorBottom = floorTop+GameConfig.floorHeight-GameConfig.floorBorder;
			if(roleTop<=(floorTop-5)){
				this.isJumpingUp = false;
				this.isJumpingDown = true;
				this.downSpeed = UserData.roleSpeed.roleDownSpeed;
			}
		}else if(!this.isJumpingUp && this.isJumpingDown){
			if(!this.isOnlyJumpUp){
				// 人物加速往下掉，梯步也往下掉
				// 移动梯步
				this.moveAllFloor(UserData.roleSpeed.floorDownSpeed);
			}
			this.downSpeed = this.downSpeed + UserData.roleSpeed.gravity;
			this.roleGroup.y = this.roleGroup.y+this.downSpeed;
			let roleBottom = this.roleGroup.y+this.roleGroup.height;
			let floorBottom = this.currentFloor.parent.y+this.currentFloor.y+GameConfig.floorHeight-GameConfig.floorBorder;
			if(roleBottom>=(floorBottom+1)){
				this.isJumpingUp = false;
				this.isJumpingDown = false;
				this.updateRoleXY();
				if(this.isOnlyJumpUp){
					this.isJumping = false;
				}
			}
			
		}else if(!this.isJumpingUp && !this.isJumpingDown){
			// 人物加速往下掉，梯步相同速度往下掉
			let downSpeed = UserData.roleSpeed.floorDownSpeed;
			let currentFloorY = this.currentFloor.parent.y+this.currentFloor.y;
			let halfHeight = GameConfig.stageHeight*0.5;

			this.moveAllFloor(downSpeed);
			this.updateRoleXY();
			
			
			let moveDelta = (currentFloorY-this.currentFloorFromMoveY);
			if(moveDelta>=GameConfig.floorHeight && (halfHeight-currentFloorY)<=GameConfig.floorHeight){
				this.isJumping = false;
			}
			if(currentFloorY>= halfHeight){
				this.isJumping = false;
			}
		}else{
			this.isJumping = false;
		}
	}
	private showQucikRunFire(){
		if(this.isQuickJumping){
			if(this.isRoleFromLeft2Right){
				if(!this.quickRunAramture1){
					this.quickRunAramture1 = FuncUtil.dragonBoneTween("quickFire1", "Sprite");
				}
				if(this._curQuickRunAramture != this.quickRunAramture1){
					if(this._curQuickRunAramture != null){
						if(this._curQuickRunAramture.animation.isPlaying){
							this._curQuickRunAramture.animation.stop();
						}
						let animaDisplay = this._curQuickRunAramture.display as egret.DisplayObject;
						if(animaDisplay && animaDisplay.parent){
							animaDisplay.parent.removeChild(animaDisplay);
						}
					}
					this._curQuickRunAramture = null;
					this._curQuickRunAramture = this.quickRunAramture1;
				}
			}else{
				if(!this.quickRunAramture2){
					this.quickRunAramture2 = FuncUtil.dragonBoneTween("quickFire2", "Sprite");
				}
				if(this._curQuickRunAramture != this.quickRunAramture2){
					if(this._curQuickRunAramture != null){
						if(this._curQuickRunAramture.animation.isPlaying){
							this._curQuickRunAramture.animation.stop();
						}
						let animaDisplay = this._curQuickRunAramture.display as egret.DisplayObject;
						if(animaDisplay && animaDisplay.parent){
							animaDisplay.parent.removeChild(animaDisplay);
						}
					}
					this._curQuickRunAramture = null;
					this._curQuickRunAramture = this.quickRunAramture2;
				}
			}
			let animaDisplay = this._curQuickRunAramture.display as egret.DisplayObject;
			if(animaDisplay && !animaDisplay.parent){
				this.roleGroup.addChildAt(animaDisplay,0);
			}
			if(this.isRoleFromLeft2Right){
				animaDisplay.x = this.roleGroup.width*0.5;
				animaDisplay.y = this.roleGroup.height*0.5;
			}else{
				animaDisplay.x = this.roleGroup.width*0.5;
				animaDisplay.y = this.roleGroup.height*0.5;
			}
			if(!this._curQuickRunAramture.animation.isPlaying){
				this._curQuickRunAramture.animation.play();
			}
		}else{
			if(this._curQuickRunAramture){
				let displayAnim = this._curQuickRunAramture.display as egret.DisplayObject;
				if(this._curQuickRunAramture.animation.isPlaying){
					this._curQuickRunAramture.animation.stop();
				}
				if(displayAnim && displayAnim.parent){
					displayAnim.parent.removeChild(displayAnim);
				}
			}
		}
	}
	/**使用电梯卡移动 */
	private rocketJump2SafeFloor(){
		
		let displayAnim = this._rocketArmature.display as egret.DisplayObject;
		if(displayAnim && !displayAnim.parent){
			this.roleGroup.addChildAt(displayAnim,0);
		}
		if(this.isRoleFromLeft2Right){
			displayAnim.x = this.roleGroup.width*-0.2;
			displayAnim.y = this.roleGroup.height*0.9;
		}else{
			displayAnim.x = this.roleGroup.width*1.2;
			displayAnim.y = this.roleGroup.height*0.9;
		}
		if(!this._rocketArmature.animation.isPlaying){
			this._rocketArmature.animation.play();
		}
		let speed = 20;//UserData.roleHighSpeed.roleUpSpeed;
		this.moveAllFloor(speed);
		if(this.roleGroup.y>this.height/2){
			this.roleGroup.y = this.roleGroup.y-speed*0.5;
		}
		if(this.safeFloor){
			let safeFloorBottom = this.safeFloor.parent.y+this.safeFloor.y+GameConfig.floorHeight-GameConfig.floorBorder;
			if(safeFloorBottom >= this.height/2){
				let floorRight = this.safeFloor.x+this.safeFloor.width;
				let floorLeft = this.safeFloor.x;
				
				if(this.roleGroup.x+this.roleGroup.width>floorRight){
					this.roleGroup.x = floorRight-this.roleGroup.width;
					this.isRoleFromLeft2Right = false;
				}
				else if(this.roleGroup.x<floorLeft){
					this.roleGroup.x = floorLeft;
					this.isRoleFromLeft2Right = true;
				}
				this.isRocketJumping = false;
				this.currentFloor = this.safeFloor;
				this.safeFloor = null;
				this.updateRoleXY();
				this.addUserScore();
				if(this._rocketArmature.animation.isPlaying){
					this._rocketArmature.animation.stop();
				}
				if(displayAnim && displayAnim.parent){
					displayAnim.parent.removeChild(displayAnim);
				}
				SoundManager.stopEffect(GameConfig.music.rocket);
			}
		}
		
	}
	private getSafeFloor(){
		this.safeFloor = null;
		let index = this.currentFloor.floorIndex;
		let safeIndex = (Math.floor((index+1)/10)+1)*10-1;
		this.safeIndex = safeIndex;
		for(let i=0;i<this.floorArray.length;i++){
			let floor = this.floorArray[i];
			if(floor.floorIndex == safeIndex){
				this.safeFloor = floor;
				return;
			}
		}
	}
	private getLastSafeFloor(){
		let index = this.currentFloor.floorIndex;
		let safeIndex = Math.floor((index+1)/10)*10-1;
		for(let i=0;i<this.floorArray.length;i++){
			let floor = this.floorArray[i];
			if(floor.floorIndex == safeIndex){
				this.currentFloor = floor;
				this.addUserScore();
				return;
			}
		}
	}

	private moveAllFloor(moveY:number){
		this.floorBox1.y = this.floorBox1.y+moveY;
		this.floorBox2.y = this.floorBox2.y+moveY;
		let maxY = GameConfig.stageHeight-this.floorBottom;
		if(this.floorBox1.y >= maxY){
			
			let len = this.floorArray.length;
			for(let i=len-1;i>=0;i--){
				let floor = this.floorArray[i];
				if(floor.parent == this.floorBox1){
					GameConfig.saveFloor(floor);
					this.floorArray.splice(0,1);
				}
				
			}

			this.floorBox1.y = this.floorBox2.y-this.floorBox1.height;
			
		}
		if(this.floorBox2.y >= maxY){
			let len = this.floorArray.length;
			for(let i=len-1;i>=0;i--){
				let floor = this.floorArray[i];
				if(floor.parent == this.floorBox2){
					GameConfig.saveFloor(floor);
					this.floorArray.splice(0,1);
				}
				
			}
			this.floorBox2.y = this.floorBox1.y-this.floorBox2.height;
		}
		
	}
	private gameOver(){
		if(this.roleGroup.x>(GameConfig.stageWidth-GameConfig.floorMargin-this.roleGroup.width/2)){
			this.roleGroup.x = GameConfig.stageWidth-GameConfig.floorMargin-this.roleGroup.width/2;
		}
		if(this.roleGroup.x<(GameConfig.floorMargin+this.roleGroup.width/2)){
			this.roleGroup.x = GameConfig.floorMargin+this.roleGroup.width/2;
		}
		this.isGameOver = true;
		SoundManager.playEffect(GameConfig.music.dead);
		this.isRealGameOver = false;
		egret.Tween.get(this.roleGroup).to({y:GameConfig.stageHeight-this.floorBottom-this.roleGroup.height/2-10},1000).call(()=>{
			this.realGameOver();
		});

		egret.setTimeout(()=>{
			let lastIndex = App.UiManager.indexList[(App.UiManager.indexList.length-1)]
			if(lastIndex == this.index && this.isGameOver && !this.isRealGameOver){
				this.realGameOver();
			}
		},this,2000);
		
	}
	private realGameOver(){
		this.isRealGameOver = true;
		UserData.deadTimes = UserData.deadTimes+1;
		if(!UserData.is_verify && UserData.deadTimes <3){
			App.EventManager.dispatchEvent(GameConstants.UI_ADD_TO_PARENT, GameConfig.uiIndex.gameReborn);
		}else{
			this.isRealGameOver = true;
			this.enterGameOverScene();
		}
	}
	/**
	 * 检测添加减少梯步
	 */
	private checkRemoveFloorAndAddFloor(){
		
		let firstFloor = this.floorArray[0];
		let firstFloorY = firstFloor.parent.y+firstFloor.y;
		let maxFirstY = GameConfig.stageHeight - this.floorBottom;
		if(firstFloorY>maxFirstY){
			GameConfig.saveFloor(firstFloor);
			this.floorArray.splice(0,1);
			
		}
		// 人物高度超过中间需要添加梯子
		let lastFoor = this.lastFloor;
		let lastFoorY = lastFoor.parent.y+lastFoor.y;
		if(lastFoorY>=-GameConfig.floorHeight*0){
			let newFloor = GameConfig.getFoor(this.lastFloor);
			if(newFloor.floorIndex == this.safeIndex){
				this.safeFloor = newFloor;
			}
			this.lastFloor = newFloor;
			if(newFloor.hardLevel.lastFloorY == 0){
				newFloor.hardLevel.lastFloorY = this.floorBox1.height;
			}	
			this.floorArray.push(newFloor);
			this.curfloorBox.addChild(newFloor);
			if(newFloor.y == 0){
				newFloor.hardLevel.lastFloorY = this.floorBox1.height;
				if(this.curfloorBox == this.floorBox1){
					this.curfloorBox = this.floorBox2;
				}else{
					this.curfloorBox = this.floorBox1;
				}
			}
		}
		
	}
	
	/**
	 * 进入GameOver页面
	 */
	private enterGameOverScene()
	{
		/**判断是否需要保存分数到微信远程数据库*/
		this.checkSaveScore2WXCloudStorage();
	}
	/**判断是否需要保存分数到微信远程数据库*/
	private checkSaveScore2WXCloudStorage() {

		UserData.score_isWIN = false;
		if(UserData.highest_score<UserData.score){
			UserData.highest_score = UserData.score;
			UserData.score_isWIN = true;
		}
		// 以打破周记录为刷新记录
		if(UserData.week_highest_score<UserData.score){
			UserData.week_highest_score = UserData.score;
			
		}
		// 刷新本周记录，要保存
		if (UserData.score_isWIN) {//新纪录，要保存
			
			// 以周围单位的年周, 最终组合成score201810 代表含义：2018年第10周的最高分
			let yearWeek = FuncUtil.getKey();
			// 存储的数据以此为历史最高分、本周最高分、当前用户id
			let data = [
				{
					key: GameConfig.gameName+"highest_score",
					value: UserData.highest_score + ""
				},
				{
					key: GameConfig.gameName+'score'+yearWeek,
					value: UserData.week_highest_score + ""
				},
				{
					key: GameConfig.gameName+"id",
					value: UserData.id + ""
				}
				
			];
			// 微信数据存储成功后，请求接口更新用户信息
			platform.setUserCloudStorage(data, this.requestUpdateGameResult.bind(this));
		} else {
			// 没有刷新本周纪录，直接进入下一步
			UserData.score_isWIN = false;
			// 请求接口更新用户信息
			this.requestUpdateGameResult();
		}
	}
	/**提交分数数据成功 */
	private requestUpdateGameResult() {
		/**分数保存 */
		//UserData.gameDiamondNum = 1000;
		let param = { score: UserData.score, diamond: UserData.gameDiamondNum, rlcoin:UserData.reborn_coin }
		App.HttpRequestManager.request(NetConstants.GAME_OVER_REQUEST, param, this.responseUpdateGameResult.bind(this));
	}
	/**更新用户信息 */
	private responseUpdateGameResult(res:any)
	{
		if (res && res.statusCode == 200 && res.data.code == 0) {
			// 更新用户信息
			UserData.saveUserInfo(res.data.data);
			UserData.gameDiamondNum = 0;
			// 跳转到gameOver
			this.jumpToGameOverScene();
		} else {
			// 打印错误信息
			this.jumpToGameOverScene();
		}
	}
	/**跳到gameOver页面 */
	private jumpToGameOverScene()
	{
		let date = new Date();
		let score_isWin_Date = ""+date.getFullYear()+(date.getMonth()+1)+date.getDate();
		UserData.save2Local();
		if(UserData.score_isWIN && score_isWin_Date != UserData.last_score_isWin_Date){
			UserData.last_score_isWin_Date = score_isWin_Date;
			UserData.save2Local();
			App.EventManager.dispatchEvent(GameConstants.UI_ADD_TO_PARENT, GameConfig.uiIndex.recommend);
		}else{
			App.EventManager.dispatchEvent(GameConstants.UI_ADD_TO_PARENT, GameConfig.uiIndex.over);
		}
		
		
	}
	private changeBgImg(){
		this.bgImg.source = "bg"+UserData.current_bgId+"_jpg";
		for(let i=0;i<GameConfig.globalBgImgs.length;i++){
			let rowBgImg = GameConfig.globalBgImgs[i];
			rowBgImg.source = "bgRow"+UserData.current_bgId+"_jpg";
		}
		
	}
	private rocketBtnClicked(evt:egret.TouchEvent){
		// 防止事件流穿透
		evt.stopPropagation();
		 switch (evt.type) {
			case egret.TouchEvent.TOUCH_END:
				if(this.isGameOver || this.isPause || this.isJumping || this.isRocketJumping){
					return;
				}
				this.closeFingerImg();
				if(UserData.rocketCardNum>0){
					UserData.rocketCardNum = UserData.rocketCardNum-1;
					this.rocketNumLbl.text = "x"+UserData.rocketCardNum;
					this.isRocketJumping = true;
					this.safeFloor = null;
					this.getSafeFloor();	

					if(this._rocketArmature){
						let disObj = this._rocketArmature.display as egret.DisplayObject;
						if(disObj && disObj.parent){
							disObj.parent.removeChild(disObj);
						}
						this._rocketArmature = null;
					}
					let rocketName = "rocket1";
					if(!this.isRoleFromLeft2Right){
						rocketName = "rocket2";
					}
					this._rocketArmature = FuncUtil.dragonBoneTween(rocketName, "Sprite");
					SoundManager.playEffect(GameConfig.music.rocket);				
				}else{
					TipsUtils.showTipsDownToUp("火箭卡不足");
				}
				break;
		 }

	}
	private speedBtnClicked(evt:TouchEvent){
		switch (evt.type) {
            case egret.TouchEvent.TOUCH_END:
				if(this.isGameOver || this.isPause || this.isJumping || this.isRocketJumping){
					return;
				}
				this.closeFingerImg();
				if(UserData.speedCardNum>0){
					UserData.speedCardNum = UserData.speedCardNum-1;
					this.speedNumLbl.text = "x"+UserData.speedCardNum;
					this.beginHighSpeed(5);
				}else{
					TipsUtils.showTipsDownToUp("加速卡不足");
				}
				break;
		 }
	}
	/**开始高速移动 */
	private beginHighSpeed(continueTime:number){
		UserData.roleSpeed = UserData.roleHighSpeed;
		this.showQucikRunFire();
		this.isQuickJumping = true;
		this.highSpeedBeginTime = (new Date()).getTime();
		this.highSpeedContinueTime = continueTime*1000;
	}
	/**结束告诉移动 */
	private checkStopHighSpeed(){
		if(this.highSpeedBeginTime <= 0){
			return;
		}
		let nowTime = (new Date()).getTime();
		if((nowTime-this.highSpeedBeginTime)>=this.highSpeedContinueTime){
			UserData.roleSpeed = UserData.roleNormalSpeed;
			this.showQucikRunFire();
			this.isQuickJumping = false;
		}else{
			
		}
	}
	private pauseGame(evt:egret.TouchEvent){
		evt.stopPropagation();
		this.isPause = true;
		App.EventManager.dispatchEvent(GameConstants.UI_ADD_TO_PARENT, GameConfig.uiIndex.pause);
	}
	private pausePanel2Start(){
		this.isPause = false;
		// 回到开始页面后重新发送要展示使用共享数据域展示超越排名的功能
		if(GameConfig.showGameScenceRank){
			//OpenDataUtil.showRank(this,{uiIndex: this.index});
		}
	}
	private pausePanel2ReStart(){
		this.resetDataAndViews();
		this.setupDataAndViews();
	}
	private rebornCoin2Reborn(){
		this.isGameOver = false;
		this.isJumping = false;
		this.isRocketJumping = false;
		this.isReborning = true;

		let index = this.currentFloor.floorIndex;
		let safeIndex = Math.floor((index+1)/10)*10-1;
		let len = this.floorArray.length;
		for(let i=0;i<len;i++){
			let floor = this.floorArray[i];
			GameConfig.saveFloor(floor);
		}
		this.floorArray = [];
		this.floorBox1.y = GameConfig.stageHeight-this.floorBottom-this.floorBox1.height;
		this.floorBox2.y = this.floorBox1.y-this.floorBox2.height;
		this.currentFloor = null;
		this.safeFloor = null;
		let len2 = Math.floor((GameConfig.stageHeight-this.floorBottom+GameConfig.floorHeight-1)/GameConfig.floorHeight);
		this.curfloorBox = this.floorBox1;
		let lastFloorY = this.floorBox1.height;
		let fromIndex = safeIndex-Math.floor(len2/2);
		for(let i=0;i<len2;i++){
			let floor:GameFloor = null;
			if(i==0){
				let lastHardLevel = GameHardLevel.createFirstLevel(lastFloorY,fromIndex);
				floor = new GameFloor(lastHardLevel);
			}else{
				floor = GameConfig.getFoor(this.lastFloor);
			}
			this.lastFloor = floor;
			this.curfloorBox.addChild(floor);
			if(floor.y == 0){
				floor.hardLevel.lastFloorY = this.floorBox1.height;
				this.curfloorBox = this.floorBox2;
			}
			if(floor.floorIndex==safeIndex){
				this.currentFloor = floor;
			}
			this.floorArray.push(floor);
		}
		// this.getLastSafeFloor();
		// let currentFloorY = this.getFloorYInWindow(this.currentFloor);
		// let maxY = GameConfig.stageHeight-this.floorBottom-GameConfig.floorHeight;
		// if(currentFloorY>maxY){
		// 	this.moveAllFloor(maxY-currentFloorY);
		// }
		//
		this.addUserScore();
		this.updateRoleXY();
	}
	private showGiftPackage(){
		UserData.hasGiftPackage = true;
		this.giftGroup.visible = true;
		if(this.currentFloor.giftImg && this.currentFloor.giftImg.parent){
			this.currentFloor.giftImg.parent.removeChild(this.currentFloor.giftImg);
		}
		this.currentFloor.giftImg = null;
		this.isPause = true;
	}
	private useGift(evt:TouchEvent){
		switch (evt.type) {
            case egret.TouchEvent.TOUCH_END:
				// 策略A
			let query = {from:GameConfig.shareFrom.homePage2Share};
			let shareData = GameConfig.getShareData(GameConfig.shareInfoA,query);
			Utils.shareAppMessageWithCheckGroup(shareData,(shareSuccess:boolean,shareTicket:string,iv:string,encryptedData:string)=>{
				if(UserData.is_verify){
					this.addGiftRocketSpeedCard();
					return;
				}
				if(!shareSuccess){
					 egret.Tween.get(this).wait(50).call(() => {
						TipsUtils.showTipsDownToUp("分享失败");
					 });
					
				}
				else if(shareSuccess && !shareTicket){
					egret.Tween.get(this).wait(50).call(() => {
						TipsUtils.showTipsDownToUp("分享到群才能生效");
					 });
					
				}
				else if(shareTicket && !iv){
					egret.Tween.get(this).wait(50).call(() => {
						TipsUtils.showTipsDownToUp("获取分享信息失败~~~~");
					 });
					
				}
				else if(iv && encryptedData){
					this.requestShareResult(iv,encryptedData);
				}
				
			},this);
			break;
		}

	}
	
	private requestShareResult(iv:string,encryptedData:string){
		let param = {iv:iv,encryptedData:encryptedData}
		App.HttpRequestManager.request(NetConstants.SHARE_DIFF_GROUP, param, this.responseShareResult.bind(this));
	}
	private responseShareResult(res){
		if(res.statusCode == 200 && res.data.code == 0){
			 this.addGiftRocketSpeedCard();
		}else{
			 egret.Tween.get(this).wait(50).call(() => {
    			TipsUtils.showTipsDownToUp("每个群每天只能分享1次");
			 });
		}
	}
	/**
	 * 将分享成功的礼物添加火箭卡、加速卡
	 */
	private addGiftRocketSpeedCard(){
		egret.Tween.get(this).wait(50).call(() => {
			TipsUtils.showTipsDownToUp("分享成功，获得5张火箭卡，5张加速卡");
			});
		
		UserData.rocketCardNum = UserData.rocketCardNum+5;
		if(UserData.rocketCardNum>20){
			UserData.rocketCardNum = 20;
		}
		this.rocketNumLbl.text = "x"+UserData.rocketCardNum;
		UserData.speedCardNum = UserData.speedCardNum+5;
		if(UserData.speedCardNum>20){
			UserData.speedCardNum = 20;
		}
		this.speedNumLbl.text = "x"+UserData.speedCardNum;
		// 让分享礼物消失
		this.giftGroup.visible = false;
		this.giftImg.visible = false;
		this.isPause = false;
	}
	private closeGiftPanel(){
		this.giftGroup.visible = false;
		this.giftImg.visible = true;
		this.isPause = false;
		
	}
	public addListener() {
		super.addListener();
		platform.callPlatformMethod("triggerGC",{});

		this.scoreGroup.addEventListener(egret.TouchEvent.TOUCH_TAP,this.roleJump,this);
		ViewUtils.addTapEvent(this.rocketBtn,this.rocketBtnClicked,this,{scaleX:0.9,scaleY:0.9});
		ViewUtils.addTapEvent(this.speedBtn,this.speedBtnClicked,this,{scaleX:0.9,scaleY:0.9});
		ViewUtils.addTapEvent(this.useGiftBtn,this.useGift,this,{scaleX:0.9,scaleY:0.9});
		this.closeGiftBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.closeGiftPanel,this);
		this.giftImg.addEventListener(egret.TouchEvent.TOUCH_TAP,this.showGiftPackage,this);
		this.pauseBtn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.pauseGame,this);


		App.EventManager.addEventListener(GameConstants.CHANGE_GAME_BG,this.changeBgImg,this);

		// 从暂停回到开始
		App.EventManager.addEventListener(GameConstants.GAME_FINISH_PAUSE_TO_START,this.pausePanel2Start,this);
		// 在gameReborn里使用复活币复活
		App.EventManager.addEventListener(GameConstants.GAME_RELIVE,this.rebornCoin2Reborn,this);
		// 从暂停重新开始
		App.EventManager.addEventListener(GameConstants.GAME_FINISH_PAUSE_TO_RESTART,this.pausePanel2ReStart,this);
		// 进入复活页面后倒计时结束或点击了跳过
		App.EventManager.addEventListener(GameConstants.GAME_OVER,this.enterGameOverScene,this);
		
	}
	public removeListener() {
		super.removeListener();
		platform.callPlatformMethod("triggerGC",{});

		this.scoreGroup.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.roleJump,this);
		ViewUtils.removeTapEvent(this.rocketBtn,this);
		ViewUtils.removeTapEvent(this.speedBtn,this);
		ViewUtils.removeTapEvent(this.useGiftBtn,this);
		this.closeGiftBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.closeGiftPanel,this);
		this.giftImg.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.showGiftPackage,this);
		this.pauseBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.pauseGame,this);

		App.TimerManager.remove(this.loopRunGame,this);
		App.EventManager.removeEventListener(GameConstants.CHANGE_GAME_BG,this.changeBgImg,this);

		// 从暂停回到开始
		App.EventManager.removeEventListener(GameConstants.GAME_FINISH_PAUSE_TO_START,this.pausePanel2Start,this);
		// 在gameReborn里使用复活币复活
		App.EventManager.removeEventListener(GameConstants.GAME_RELIVE,this.rebornCoin2Reborn,this);
		// 从暂停重新开始
		App.EventManager.removeEventListener(GameConstants.GAME_FINISH_PAUSE_TO_RESTART,this.pausePanel2ReStart,this);
		// 进入复活页面后倒计时结束或点击了跳过
		App.EventManager.removeEventListener(GameConstants.GAME_OVER,this.enterGameOverScene,this);

		//OpenDataUtil.cancleRank(this);
	}
}